Skip to content

Comments

CDAPI-68 Enable trivy scanning and enhance preview environemnt workflow#14

Merged
neil-sproston merged 1 commit intomainfrom
CDAPI-68enableTrivy
Feb 4, 2026
Merged

CDAPI-68 Enable trivy scanning and enhance preview environemnt workflow#14
neil-sproston merged 1 commit intomainfrom
CDAPI-68enableTrivy

Conversation

@neil-sproston
Copy link
Contributor

@neil-sproston neil-sproston commented Jan 21, 2026

Description

  • Enhanced reported messages
  • Runs a simple smoketest
  • Removes comments from previous workflow runs
  • Adds trivy scanning and reports as a comment
  • Generates SBOM aritfact

Context

This change provide trivy scanning of the lambda code thus satisfying a red-line requirement.

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • Exceptions/Exclusions to coding standards (e.g. #noqa or #NOSONAR) are included within this Pull Request.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@github-actions
Copy link

github-actions bot commented Jan 26, 2026

Trivy gate: no Critical/High vulnerabilities.

Trivy Filesystem Scan Summary

Filesystem: /tmp/artifact

Severity Count
CRITICAL 0
HIGH 0
MEDIUM 0
LOW 0
UNKNOWN 0

✅ No vulnerabilities found.

@NHSDigital NHSDigital deleted a comment from github-actions bot Jan 26, 2026
@NHSDigital NHSDigital deleted a comment from github-actions bot Jan 26, 2026
@NHSDigital NHSDigital deleted a comment from github-actions bot Jan 26, 2026
@NHSDigital NHSDigital deleted a comment from github-actions bot Jan 26, 2026
@neil-sproston neil-sproston changed the title Make it different for demo CDAPI-68 Enable trivy scanning and enhance preview environemnt workflow Jan 26, 2026
@neil-sproston neil-sproston marked this pull request as ready for review February 3, 2026 16:22
@neil-sproston neil-sproston requested a review from a team as a code owner February 3, 2026 16:22
Copy link
Collaborator

@nhsd-jack-wainwright nhsd-jack-wainwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 , just some minor comments / questions.

});

# ---------- Perform trivy scan and notify ----------
- name: Prepare lambda artifact for trivy scan
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be better to run the trivy steps here as part of the stage-1-commit.yaml workflow rather than the preview-env workflow? It would mean that you may need to run the make build target again but would keep it together with the existing scan-dependencies job.

Copy link
Contributor Author

@neil-sproston neil-sproston Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe - I do like having it in the PR as akin to the sonarcloud messages...
Currently it will always setup the preview environment for the user but will fail hard as a quality gate if any critical problems are found

format: spdx-json
output: sbom.spdx.json

- name: Trivy SBOM Dependency Graph Upload
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would this dependency graph be uploaded currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not currently uploading it in our workflow. This a non-default option for uploading the dependency graph to our github repo.
This functionality is included as we are planning to contribute it "upstream"

if: github.event.action != 'closed'
uses: ./.github/actions/trivy-fs-sbom
with:
fs-path: /tmp/artifact
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is looking at the files retrieved from the bundled artifact.zip, I think Trivy will be scanning the code of any dependencies alongside the Pathology API source code. Should this step instead be looking at the pathology-api directory at the root of the repository instead?

run: cat trivy_fs_report.md >> "$GITHUB_STEP_SUMMARY"

- name: Update Trivy PR comment
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this PR comment update as PRs are subsequently updated after being initially created?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes they are updated - this action is based as closely as possible to the "upstream" action which we want to contribute back to. That action uses a "sticky" comment so it does update but does not appear at the end each time - not my preference but is in line with current practive in the nhs-england-tools actions.


- name: Update Trivy PR comment
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }}
uses: marocchino/sticky-pull-request-comment@v2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the version of the Github action here be pinned to a commit hash rather than a version number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our actions yes we do - however this action is based as closely as possible on the action in nhs-england-tools so that we can rapidly contribute back to "upstream" hence we follow there practice in this action.


- name: Trivy SBOM SPDX Scan - Docker Image
if: ${{ inputs.image-ref != '' }}
uses: aquasecurity/trivy-action@0.28.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the version of the trivy-action here be pinned to a commit hash rather than a version number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our actions yes we do - however this action is based as closely as possible on the action in nhs-england-tools so that we can rapidly contribute back to "upstream" hence we follow there practice in this action.

fi

- name: Trivy fs scan
uses: aquasecurity/trivy-action@0.28.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, should the version of the trivy-action here be pinned to a commit hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our actions yes we do - however this action is based as closely as possible on the action in nhs-england-tools so that we can rapidly contribute back to "upstream" hence we follow there practice in this action.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Deployment Complete

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

@neil-sproston neil-sproston merged commit d9b2203 into main Feb 4, 2026
53 checks passed
@neil-sproston neil-sproston deleted the CDAPI-68enableTrivy branch February 4, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants